<?php
        @header("Content-Type:text/html;charset=utf-8");
        $connect=mysqli_connect("localhost","root","root","2101");
        
        if(!$connect){
            exit("数据库连接失败");
        }else{
            // echo "成功";
        }
        mysqli_query($connect,"set names utf8");//从数据库取数据时 将编码转为utf-8;

        mysqli_query($connect,"set character set utf-8");//向数据库传入数据  将编码转为utf-8
        $user=&$_GET['user'];
        $pwd=&$_GET['pwd'];
        $phone=&$_GET['phone'];
        $email=&$_GET['email'];
        $sqlstr="select * from `regi` where user='$user' or phone='$phone' or email='$email'";
        $querystr=mysqli_query($connect,$sqlstr);
        $result=mysqli_fetch_assoc($querystr);
        // $result=mysqli_fetch_assoc($querystr);
        $arr=array();
        if($result){    
            $arr["status"]=false;
            $arr["detail"]="用户已存在";
            echo json_encode($arr);
        }else{
            $sqlstr1="insert into `regi`(user,pwd,phone,email) values('$user','$pwd','$phone','$email')";
            mysqli_query($connect,$sqlstr1);
            $row=mysqli_affected_rows($connect);
            if($row){
                $arr["status"]=true;
                $arr["detail"]="注册成功";
               echo json_encode($arr);
            }else{
                $arr["status"]=false;
                $arr["detail"]="新增失败";
                echo json_encode($arr); 
            }
        }
?>